/**
  * @file		main.h
  * @author		Naresuan University: Advance Computer System, class of 2013
  * @version	V1.0.0
  * @date		18-September-2013
  * @brief		Main program
  */

/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "serial.h"
#include "gpio.h"
#include "analog.h"
#include "pwm.h"
#include "arduino.h"
#include "labview.h"

/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
static uint8_t cmdBuffer[COMMANDLENGTH];

/* Private function prototypes -----------------------------------------------*/
void Board_config(void);

/* Private functions ---------------------------------------------------------*/
void Board_config() 
{
	Serial_begin(9600);
	ADC_config();
	PWM_config(1000);
	syncLV();
}


/**
  * @brief		Main program: configure on-board hardware, then main loop
  * @param		None
  * @retval		None
  */
int main()
{
	int i;
	
	Board_config();
	while(1) {
		if (checkForCommand() != 0) {
			for (i = 0; i < COMMANDLENGTH; i++) {
				cmdBuffer[i] = Serial_read();
			}
			processCommand(cmdBuffer);
		}
	}
}


